import urllib.request
import ssl
import json

if __name__ == '__main__':
    # cmdline.execute('scrapy crawl ce_tech --nolog'.split())
    letter = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u',
              'v', 'w', 'x', 'y', 'z']

    count = 0
    context = ssl._create_unverified_context()
    url = "https://checkapi.aliyun.com/check/checkdomain?domain=%s.site&command=renew&token=Ya9f85c62ebed6687a83b95f9fe1eea54"
    for i in letter:
        for x in letter:
            for y in letter:
                try:
                    l = i+x+y
                    count += 1
                    print('The %s request===> %s' % (count, l))
                    response = urllib.request.urlopen(url % l, context=context)
                    data = json.load(response)
                    # print(data)
                    if data['success']:
                        ele = data['module'][0]
                        if ele['avail'] == 1 and ele['price'] is None:
                            print("Avail domain-->[%s]" % l+".site")
                    # print(response.read().decode("utf-8"))
                except Exception as e:
                    print(e)
    print(count)

